package com.example.juc.until;

import org.junit.Test;

public class goupiao {

void ss(){
    try {
    }finally {
    }

}

}
class Ter implements  Runnable{
    private static int num=30;
    public static void main(String[] args) throws InterruptedException {
        Thread.sleep(1);
        Thread t1= new Thread(new Ter(), "aa");
        Thread t2= new Thread(new Ter(),"bb");
        Thread t3= new Thread(new Ter(),"cc");
        t1.start();
        t2.start();
        t3.start();
    }

    @Override
    public void run() {
        while (true) {
            synchronized ("suo"){
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                if(num>0)
                    System.out.println(Thread.currentThread().getName()+"购买一张:还剩"+(num--));

            }
        }
    }
}